<?php
namespace api\jeu\map;

class map {

	public $width;
	public $height;
	
	private $_cases = array();
	
	private $_map;
	
	private $_phase = null;
	private $_instance = null;
	
	public function __construct($width, $height) {
		$this->width = $width;
		$this->height = $height;	
	}	
	
	public function setCase($x,$y, iCases $case) {
		$pos = $this->position($x,$y);
		$this->_cases[$this->position($x,$y)] = $case;
		return true;
	}
	
	public function getCase($x,$y) {
		if(isset($this->_cases[$this->position($x,$y)])){
			return $this->_cases[$this->position($x,$y)];
		}
		return false;
	}
	
	private function position($x,$y) {
		return (($x-1) * $this->width) + $y;
	}
	
	public function toString() {
		$buffer=null;
		
		foreach($this->_cases as $key => $cases){
			$buffer .= $key.':'.$cases->toString().' | ';
		}
		
		return $buffer;
	}

}